<style>
  :host {
    --tabstrip-tab-transition-duration: 250ms;

    display: block;
    height: var(--tabstrip-tab-height);
    padding-inline-end: var(--tabstrip-tab-spacing);
    position: relative;
    transform-origin: top left;
    width: var(--tabstrip-tab-width);
  }

  :host-context([dir='rtl']) {
    transform-origin: top right;
  }

  :host([dragged-out_]) {
    display: none;
  }

  #tab {
    background: var(--tabstrip-tab-background-color);
    border-radius: var(--tabstrip-tab-border-radius);
    box-shadow: 0 0 0 1px var(--tabstrip-tab-separator-color);
    color: var(--tabstrip-tab-text-color);
    display: flex;
    flex-direction: column;
    height: var(--tabstrip-tab-height);
    overflow: hidden;
    width: var(--tabstrip-tab-width);
  }

  #tab:focus {
    outline: none;
  }

  :host-context(.focus-outline-visible) #tab:focus {
    box-shadow: 0 0 0 2px var(--tabstrip-focus-outline-color);
  }

  :host([active]) #tab {
    box-shadow: 0 0 0 2px var(--tabstrip-tab-active-border-color);
  }

  :host-context(.focus-outline-visible):host([active]) #tab:focus {
    box-shadow: 0 0 0 4px var(--tabstrip-focus-outline-color),
                0 0 0 2px var(--tabstrip-tab-active-border-color);
  }

  #title {
    align-items: center;
    border-block-end: 1px solid var(--tabstrip-tab-separator-color);
    box-sizing: border-box;
    display: flex;
    height: var(--tabstrip-tab-title-height);
    justify-content: center;
    margin: 0;
    overflow: hidden;
  }

  #faviconContainer {
    --favicon-size: 16px;
    flex-shrink: 0;
    height: var(--favicon-size);
    margin-inline-end: 8px;
    margin-inline-start: 12px;
    max-width: var(--favicon-size);
    position: relative;
    /* When transitioning to the default visible state, the margin and max-width
     * transitions should finish first, then the opacity should be set to 1.
     * This prevents the favicon and loading spinners from looking cropped
     * while the element transitions. */
    transition: margin var(--tabstrip-tab-transition-duration),
                max-width var(--tabstrip-tab-transition-duration),
                opacity 0ms linear var(--tabstrip-tab-transition-duration);
    width: var(--favicon-size);
  }

  :host([hide-icon_]) #faviconContainer {
    margin-inline-end: 0;
    max-width: 0;
    opacity: 0;
    /* When transitioning to the hidden state, set opacity immediately to 0
     * while transitioning the other values normally. */
    transition: margin var(--tabstrip-tab-transition-duration),
                max-width var(--tabstrip-tab-transition-duration),
                opacity 0ms;
  }

  :host([pinned]) #faviconContainer {
    margin: 0;
  }

  :host([touch_pressed_]) #dragImage {
    transform: scale(1.1);
    transform-origin: center;
    transition-duration: 300ms;
  }

  #progressSpinner,
  #favicon,
  #crashedIcon {
    height: var(--favicon-size);
    left: 50%;
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: var(--favicon-size);
  }

  #progressSpinner {
    -webkit-mask:
        url(chrome://resources/images/throbber_small.svg)
        center/contain no-repeat;
    display: none;
  }

  #favicon {
    background-size: contain;
    transition: border-radius var(--tabstrip-tab-transition-duration);
  }

  #crashedIcon {
    -webkit-mask:
        url(chrome://theme/IDR_CRASH_SAD_FAVICON@2x)
        center/contain no-repeat;
    background-color: currentColor;
    opacity: 0;
    transform: translate(-50%, 100%);
  }

  #blocked {
    background: var(--tabstrip-tab-blocked-color);
    border: solid 1px var(--tabstrip-tab-background-color);
    border-radius: 50%;
    bottom: 0;
    display: none;
    height: 6px;
    position: absolute;
    right: 0;
    transform: translate(50%, 50%);
    width: 6px;
  }

  :host([waiting_]) #progressSpinner,
  :host([loading_]) #progressSpinner {
    display: block;
  }

  :host([loading_]) #favicon {
    border-radius: 50%;
    height: calc(var(--favicon-size) - 6px);
    overflow: hidden;
    width: calc(var(--favicon-size) - 6px);
  }

  :host([waiting_]) #progressSpinner {
    background-color: var(--tabstrip-tab-waiting-spinning-color);
    transform: /* Center first, then flip horizontally. */
              translate(-50%, -50%) scaleX(-1);
  }

  :host([waiting_]) #favicon {
    display: none;
  }

  :host([loading_]) #progressSpinner {
    background-color: var(--tabstrip-tab-loading-spinning-color);
  }

  :host([crashed_]) #favicon {
    opacity: 0;
    transform: translate(-50%, 100%);
    transition:
        opacity var(--tabstrip-tab-transition-duration),
        transform var(--tabstrip-tab-transition-duration);
  }

  :host([crashed_]) #crashedIcon {
    opacity: 1;
    transform: translate(-50%, -50%);
    transition:
        opacity var(--tabstrip-tab-transition-duration),
        transform var(--tabstrip-tab-transition-duration);
    /* Wait until transition for #favicon finishes. */
    transition-delay: var(--tabstrip-tab-transition-duration);
  }

  :host([blocked_]) #blocked {
    display: block;
  }

  :host([active][blocked_]) #blocked {
    display: none;
  }

  #titleText {
    flex: 1;
    font-size: 100%;
    font-weight: normal;
    overflow: hidden;
    position: relative;
    white-space: nowrap;
  }

  #titleText::after {
    background: linear-gradient(
        to right, transparent, var(--tabstrip-tab-background-color));
    content: '';
    display: block;
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    width: 3ch;
  }

  :host-context([dir='rtl']) #titleText::after {
    background: linear-gradient(
        to left, transparent, var(--tabstrip-tab-background-color));
    left: 0;
    right: auto;
  }

  :host([has-alert-states_]) #titleText {
    margin-inline-end: 4px;
  }

  #close {
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    align-items: center;
    background-color: transparent;
    border: 0;
    color: inherit;
    cursor: pointer;
    display: flex;
    flex-shrink: 0;
    height: 100%;
    justify-content: center;
    outline: none;
    padding: 0;
    position: relative;
    width: 36px;
  }

  #closeIcon {
    -webkit-mask:
        url(chrome://resources/images/icon_clear.svg) center/contain no-repeat;
    background-color: currentColor;
    display: block;
    height: 18px;
    position: relative;
    width: 18px;
  }

  :host-context(.focus-outline-visible) #close:focus #closeIconFocus {
    background: currentColor;
    border-radius: 50%;
    height: 24px;
    opacity: 0.16;
    position: absolute;
    width: 24px;
  }

  #thumbnail {
    align-items: flex-start;
    background: var(--tabstrip-tab-background-color);
    display: flex;
    flex: 1;
    height: var(--tabstrip-tab-thumbnail-height);
    justify-content: center;
    width: var(--tabstrip-tab-thumbnail-width);
  }

  #thumbnailImg {
    min-height: 100%;
    object-fit: cover;
    pointer-events: none;
    width: 100%;
  }

  #thumbnailImg:not([src]) {
    display: none;
    pointer-events: none;
    width: 100%;
  }

  /* Pinned tab styles */
  :host([pinned]) {
    --tabstrip-tab-height: var(--tabstrip-pinned-tab-size);
    --tabstrip-tab-width: var(--tabstrip-pinned-tab-size);
  }

  :host([pinned]) #title {
    border-block-end: 0;
    height: 100%;
  }

  :host([pinned]) #titleText,
  :host([pinned]) #close,
  :host([pinned]) #thumbnail {
    display: none;
  }

  :host([pinned][has-alert-states_]) #faviconContainer {
    display: none;
  }

  :host([dragging_]) #dragPlaceholder {
    background: var(--tabstrip-tab-background-color);
    border-radius: var(--tabstrip-tab-border-radius);
    height: 100%;
    opacity: 0.5;
    width: 100%;
  }

  /* When being dragged, the contents of the drag image needs to be off-screen
   * with nothing else on top or below obscuring it. */
  :host([dragging_]) #dragImage {
    /* Enough padding to not crop the box shadow set on #tab below. */
    --drag-image-padding: 25px;
    height: 100%;
    padding: var(--drag-image-padding);
    position: absolute;
    top: 100vh;
    width: 100%;
  }

  :host([dragging_]) #tab {
    box-shadow: var(--tabstrip-tab-dragging-shadow);
    transform: scale(var(--tabstrip-tab-drag-image-scale));
  }
</style>

<div id="dragPlaceholder"></div>

<!--
  #dragImage is a wrapper that wraps the entire #tab contents so that #tab can
  be styled with properties, such as box-shadow, that extend beyond #tab's
  boundaries and #dragImage can add padding to itself to contain all of #tab's
  styles. When the tab is not being dragged, the #dragImage parent has no use.
-->
<div id="dragImage">
  <div id="tab" role="tab" tabindex="0"
      aria-labelledby="titleText alertIndicators">
    <header id="title">
      <div id="faviconContainer" aria-hidden="true">
        <div id="progressSpinner"></div>
        <div id="favicon"></div>
        <div id="crashedIcon"></div>
        <div id="blocked"></div>
      </div>
      <h2 id="titleText"></h2>
      <tabstrip-alert-indicators id="alertIndicators">
      </tabstrip-alert-indicators>
      <button id="close" aria-describedby="titleText">
        <span id="closeIconFocus"></span>
        <span id="closeIcon"></span>
      </button>
    </header>

    <div id="thumbnail">
      <img id="thumbnailImg">
    </div>
  </div>
</div>
